    #include <mutex>
    #include <thread>
    #include <iostream>
    
    int cnt = 0;
    std::mutex mutex;
    
    void thread_1(){
        for(int i = 0;i < 100; i++){
            mutex.lock();
            std::cout << "thread_1() " << cnt++ << std::endl;
            mutex.unlock();
        }
    }
    
    void thread_2(){
        for(int i = 0;i < 100; i++){
            mutex.lock();
            std::cout << "thread_2() " << cnt++ << std::endl;
            mutex.unlock();
        }
    }
    
    int main(){
        mutex.lock();
        std::thread th1(thread_1);
        std::thread th2(thread_2);
        mutex.unlock();
        th1.join();
        th2.join();
    }